package com.ymatou.iapi.csim.testcase;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.csim.parameter.UpdateAutoReplyBean;
import com.ymatou.iapi.csim.service.UpdateAutoReplyCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.model.ymt_autoreply;
import com.ymttest.database.sqlwapper.CSIM.ymt_autoreplyWapper;
/**
*更新自动回复
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_UpdateAutoReply{
	private static UpdateAutoReplyBean bean;
	private static UpdateAutoReplyCall call;
	ymt_autoreplyWapper autoreplyWapper=new ymt_autoreplyWapper();
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("更新自动回复");
	}

	@Before
	public void caseUp() {
		bean=new UpdateAutoReplyBean();
		call=new UpdateAutoReplyCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateAutoReply_001() {
		Logger.start(true,"更新自动回复");
		try {
			
			bean.setCSType(0);
			bean.setType(1);
			bean.setMessage("自动化测试_更新自动回复");
			call.setData(bean);
			call.callService();	
			
			Map<String,Object> map=new HashMap();
			map.put("cstype", bean.getCSType());
			map.put("type", bean.getType());
			map.put("message", bean.getMessage());
			ymt_autoreply  auto=autoreplyWapper.selectby(map).get(0);
			Logger.verifyEquals("0", call.getResult().get("ErrorCode").toString(), "验证errorCode");
			Logger.verifyEquals(true, call.getResult().get("Success"), "验证Success");
			Logger.verifyEquals("200", call.getStatus(), "验证Status");
			
			Logger.verifyEquals(bean.getCSType(), auto.getCSType(), "验证ymt_autoreply表中的CSType字段");
			Logger.verifyEquals(bean.getType(), auto.getType(), "验证ymt_autoreply表中的Type字段");
			Logger.verifyEquals(bean.getMessage(), auto.getMessage(), "验证ymt_autoreply表中的Message字段");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}